Skip to main content

Weak typing

There are strong typing, weak typing and untyped languages. In strongly typed, when a variable is declared we have to include its type also. Once a variable is declared its type cannot be changed. In untyped languages, there will be no distinction between the strings, integers, functions and other data types.

In a weakly typed language, data types are not explicitly declared.

JavaScript is a weak typed language.

var sample; // data type is undefined
sample = 4; // data type is number
sample = "Hello world!"; // data type is string

First, we declare a variable sample which is empty. Actually, it's data type is undefined. Then we assign with a number 4, so now its data type is number. Then we assign a string "Hello world!", so its data type is string.

Note

Some of the strongly typed language are C, Java and Pascal.